Ajv JSON schema validator
The fastest JSON validator for Node.js and browser.
Supports JSON Schema draft-04/06/07/2019-09/2020-12 (draft-04 support requires ajv-draft-04 package) and JSON Type Definition RFC8927.
![GitHub Sponsors](https://img.shields.io/badge/$-sponsors-brightgreen)
![Mozilla](https://ajv.js.org/img/mozilla.svg)
![](https://ajv.js.org/img/gap.svg)
![](https://ajv.js.org/img/reserved.svg)
![Microsoft](https://ajv.js.org/img/microsoft.png)
![](https://ajv.js.org/img/gap.svg)
![](https://ajv.js.org/img/reserved.svg)
![](https://ajv.js.org/img/gap.svg)
![](https://ajv.js.org/img/reserved.svg)
![Retool](https://ajv.js.org/img/retool.svg)
![](https://ajv.js.org/img/gap.svg)
![Tidelift](https://ajv.js.org/img/tidelift.svg)
![](https://ajv.js.org/img/gap.svg)
![SimpleX](https://ajv.js.org/img/simplex.svg)
![](https://ajv.js.org/img/gap.svg)
![](https://ajv.js.org/img/reserved.svg)
Contributing
More than 100 people contributed to Ajv, and we would love to have you join the development. We welcome implementing new features that will benefit many users and ideas to improve our documentation.
Please review Contributing guidelines and Code components.
Documentation
All documentation is available on the Ajv website.
Some useful site links:
Since I asked to support Ajv development 40 people and 6 organizations contributed via GitHub and OpenCollective - this support helped receiving the MOSS grant!
Your continuing support is very important - the funds will be used to develop and maintain Ajv once the next major version is released.
Please sponsor Ajv via:
Thank you.
![](https://opencollective.com/ajv/individuals.svg?width=890)
![](https://opencollective.com/ajv/organization/24/avatar.svg)
Performance
Ajv generates code to turn JSON Schemas into super-fast validation functions that are efficient for v8 optimization.
Currently Ajv is the fastest and the most standard compliant validator according to these benchmarks:
Performance of different validators by json-schema-benchmark:
![performance](https://chart.googleapis.com/chart?chxt=x,y&cht=bhs&chco=76A4FB&chls=2.0&chbh=62,4,1&chs=600x416&chxl=-1:%7Cajv%7C@exodus/schemasafe%7Cis-my-json-valid%7Cdjv%7C@cfworker/json-schema%7Cjsonschema/=t:100,69.2,51.5,13.1,5.1,1.2)
Features
Install
To install version 8:
npm install ajv
Getting started
Try it in the Node.js REPL: https://runkit.com/npm/ajv
In JavaScript:
import Ajv from "ajv"
const Ajv = require("ajv")
const ajv = new Ajv()
const schema = {
type: "object",
properties: {
foo: {type: "integer"},
bar: {type: "string"},
},
required: ["foo"],
additionalProperties: false,
}
const data = {
foo: 1,
bar: "abc",
}
const validate = ajv.compile(schema)
const valid = validate(data)
if (!valid) console.log(validate.errors)
Learn how to use Ajv and see more examples in the Guide: getting started
Changes history
See https://github.com/ajv-validator/ajv/releases
Please note: Changes in version 8.0.0
Version 7.0.0
Version 6.0.0.
Code of conduct
Please review and follow the Code of conduct.
Please report any unacceptable behaviour to ajv.validator@gmail.com - it will be reviewed by the project team.
Security contact
To report a security vulnerability, please use the
Tidelift security contact.
Tidelift will coordinate the fix and disclosure. Please do NOT report security vulnerabilities via GitHub issues.
Open-source software support
Ajv is a part of Tidelift subscription - it provides a centralised support to open-source software users, in addition to the support provided by software maintainers.
License
MIT